<?php


namespace plugin\coleopenapi\app\middleware;


use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;

/**
 * 给请求都加上request_id 用于追踪请求
 * Class RequestIDMiddleware
 * @package plugin\coleopenapi\app\middleware
 */
class RequestIDMiddleware implements MiddlewareInterface
{
    public function process(Request $request, callable $handler): Response
    {
        $request->request_id = $request->header('request_id',uniqidReal());
        return $handler($request);
    }
}